#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int fragfiles(int tambuffer, int fsize)
{
	int a, b;

	a = fsize/tambuffer;
	b = fsize%tambuffer;

	if( b == 0 )
		return a;
	else
		return a + 1;
}

long int *getptr(FILE *f, int tamreg, int tambuffer,int fsize,  char *erro)
{
	int i = 0;
	int qtdfiles = fragfiles(tambuffer, fsize);
	//cria lista que contera o ponteiro para cada bloco do arquivo
	long int *ptrlist = (long int*)malloc(sizeof(long int)*qtdfiles);
	//pega os endereços e coloca na lista
	while(i < qtdfiles)
	{
		ptrlist[i] = ftell(f);
		fseek(f, tambuffer, SEEK_CUR);
		i++;
	}
	fseek(f, 0, SEEK_SET);
	return ptrlist;
}




main()
{
	FILE *f = fopen("reg1.txt", "r");
	long int *ptrlist = getptr(f, 75, 300, 750000, "erro");
	char str[400];
	fseek(f, ptrlist[20], SEEK_SET);
	fgets(str, 75, f);
 	printf("\n-->%s\n\n", str);





	fclose(f);








}